package chapter10;

import java.util.ArrayList;
import java.util.Collection;

public class Controller {
	private Collection<Event> eventList=new ArrayList<Event>();
	public void addEvent(Event e)
	{
		eventList.add(e);
	}
	public void run()
	{
		//可能有些人物还没有准备好！
		while(eventList.size()>0)
		{
			for(Event e:new ArrayList<Event>(eventList))
			{
				if(e.ready())
				{
					System.out.println(e);
					e.action();
					System.out.println(e);
					eventList.remove(e);
				}
			}
		}
	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
